/********************************************************************************
* File Name:	mainwindow.cpp
* Description:	第3章 实例20：GraphicsView的实例
* Reference book:《Linux环境下Qt4图形界面与MySQL编程》，机械工业出版社.2012.1
* E_mail: openlinux2011@gmail.com
*
********************************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QGraphicsScene>
#include <QGraphicsView>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QGraphicsScene *scene = new QGraphicsScene;
    scene->setSceneRect(-300,-300,600,600);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    QPixmap pixmap(":/1.jpg");
    pixmap = pixmap.scaledToWidth(200);
    QGraphicsPixmapItem *item1 = scene->addPixmap(pixmap);

    ui->view->setScene(scene);
    ui->view->setRenderHint(QPainter::Antialiasing);
    ui->view->setCacheMode(QGraphicsView::CacheBackground);
    ui->view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    ui->view->setDragMode(QGraphicsView::ScrollHandDrag);
    ui->view->resize(400,300);
}

MainWindow::~MainWindow()
{
    delete ui;
}


